package cn.yunhe.controller;

import cn.yunhe.entity.Flase;
import cn.yunhe.services.IFlaseServices;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2018/6/2.
 */
@RestController
@RequestMapping("/falsePrac")
public class FalseController {
    @Resource
    private IFlaseServices flaseServices;

    @RequestMapping("/saveFlase")
    public void saveByIds(int pro_id,int student_id){
        Map map=new HashMap();
        map.put("pro_id",pro_id);
        map.put("student_id",student_id);
        Flase flase=flaseServices.judgeFlase(map);

        if(flase==null){
            Map map1=new HashMap();
            map1.put("student_id",student_id);
            map1.put("pro_id",pro_id);
            map1.put("flase_count",1);
            flaseServices.addFalse(map1);
        }else{
            Map map2=new HashMap();
            map2.put("pro_id",pro_id);
            map2.put("flase_count",flase.getFlase_count()+1);

            flaseServices.updateFalse(map2);
        }


    }
    public IFlaseServices getFlaseServices() {
        return flaseServices;
    }

    public void setFlaseServices(IFlaseServices flaseServices) {
        this.flaseServices = flaseServices;
    }
}
